package com.mysoft.bmsdatacapture.web.controller;

import com.mysoft.dataexchange.service.DataExchangeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.client.ServiceInstance;
import org.springframework.cloud.client.loadbalancer.LoadBalancerClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 *
 */
@RestController
public class TestController {

    @Autowired
    protected DataExchangeService dataExchangeService;

    @Autowired
    private RestTemplate restTemplate;

    //@Autowired
    //private LoadBalancerClient loadBalancerClient;

    @GetMapping("test")
    public Map test() {

        //ServiceInstance dataExchangeClient = loadBalancerClient.choose("dataExchange");
        String url = "http://dataExchange/hi";
        Map s = restTemplate.getForObject(url, Map.class);

        //Map<String, Object> s = dataExchangeService.sayHi();
        Map map = new HashMap();
        map.put("food", "123");
        map.put("word", s);
        return map;
    }

}
